package ar.com.ford.it.fullEconomics.interfaces.threadExecutor;

import java.io.IOException;
import java.io.PrintWriter;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import commonj.timers.TimerListener;
import commonj.timers.TimerManager;

public class TestThread extends HttpServlet {


	protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException {
			// TODO Auto-generated method stub
			this.doPost(arg0,arg1);
		}
		
	
		protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
			PrintWriter out = resp.getWriter();
		
			    out.println("<html><head><title>TEST SERVLET</title></head>");
				out.println("<body>");
				//Executor.getInstance().start();
				//RunMethod rm = new RunMethod();
				//rm.execute();

				try {
//					<resource-ref id="ResourceRef_1251214739713">
//					<res-ref-name>timer/MyTimer</res-ref-name>
//					<res-type>commonj.timer.TimerManager</res-type>
//					<res-auth>Container</res-auth>
//					<res-sharing-scope>Unshareable</res-sharing-scope>
//				    </resource-ref>
					
					
					InitialContext ctx = new InitialContext();
					TimerManager mgr = (TimerManager) ctx.lookup("java:comp/env/timer/MyTimer"); //
					TimerListener listener = new TimerProductionVolumesMix();
					mgr.schedule(listener, 1000*20,1000*10);
				} catch (NamingException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
				
				
				out.println("<BR> prueba");
				out.println("<BR>");
				out.println("</body></html>");
				
				}


}


	
